package appconfig

import (
	"fmt"
	"github.com/spf13/viper"
)

type appConf struct {
	Mysql
	Redis
}
type Mysql struct {
	User     string
	Password string
	Hort     string
	Post     int
	Data     string
}
type Redis struct {
	Addr     string
	Password string
	DB       int
}

var Conf appConf

func Init() {
	viper.SetConfigFile("./appconfig/dev.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		fmt.Println("配置文件读取失败")
	}
	err = viper.Unmarshal(&Conf)
	if err != nil {
		fmt.Println("配置文件下载失败")
	}
	fmt.Println("配置文件读取成功")
}
